//
//  YanCheTableViewCell.m
//  CarTown
//
//  Created by xionghao on 15/8/5.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "YanCheTableViewCell.h"
#import "UUChart.h"
#import "ChartDataMode.h"
@interface YanCheTableViewCell ()<UUChartDataSource>
@property (nonatomic,strong) UUChart *chartView;
@property (nonatomic,strong) NSArray *dataarray;
@property (nonatomic,strong) NSArray *titlearray;
@end
@implementation YanCheTableViewCell

+(id)cellWithTabelview:(UITableView *)tableview{
    YanCheTableViewCell *cell=[tableview dequeueReusableCellWithIdentifier:@"yanchecell"];
    if (cell==nil) {
        cell=[[[NSBundle mainBundle] loadNibNamed:@"YanCheTableViewCell" owner:nil options:nil]lastObject];
    }
    return cell;
}
-(void)setMode:(YanCheModel *)mode{
    _mode=mode;
    if (mode.isChecked) {
        self.yanicon.image=[UIImage imageNamed:@"yan"];
        self.yantext.text=@"已通过验车师权威认证";
        self.yantext.textColor=UIColorWithRGB(109, 121, 196);
    }else{
        self.yanicon.image=[UIImage imageNamed:@"yan2"];
         self.yantext.text=@"暂无验车师认证";
        self.yantext.textColor=UIColorWithRGB(150, 150, 150);
    }
}
-(void)setDatamodel:(ChartDataMode *)datamodel{
    _datamodel=datamodel;
    self.dataarray=datamodel.dataarray;
    self.titlearray=datamodel.titlearray;
    [self.chartView showInView:self.charContainer];
}

#pragma mark - @required
//横坐标标题数组
- (NSArray *)UUChart_xLableArray:(UUChart *)chart
{
    
    return self.titlearray;
}
//判断显示横线条
- (BOOL)UUChart:(UUChart *)chart ShowHorizonLineAtIndex:(NSInteger)index
{
    return YES;
}
//数值多重数组
- (NSArray *)UUChart_yValueArray:(UUChart *)chart
{
    return @[self.dataarray];
    
}
//显示数值范围
- (CGRange)UUChartChooseRangeInLineChart:(UUChart *)chart
{
    if (self.dataarray) {
        return CGRangeMake(50, 0);
    }
    return CGRangeZero;
}

- (void)awakeFromNib {
    // Initialization code
}
- (NSArray *)UUChart_ColorArray:(UUChart *)chart
{
    return @[UIColorWithRGB(242, 138, 35)];
}
-(UUChart *)chartView{
    if (_chartView==nil) {
        _chartView = [[UUChart alloc]initwithUUChartDataFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width-16, 190) withSource:self withStyle:UUChartLineStyle];
        
    }
    return _chartView;
}
#pragma mark 折线图专享功能

//标记数值区域
- (CGRange)UUChartMarkRangeInLineChart:(UUChart *)chart
{
    if (self.dataarray) {
        return CGRangeMake(32, 33);
    }
    return CGRangeZero;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
